package lt.marsrutai.mobile.android.util;

import android.content.Context;
import android.util.TypedValue;

/**
 * Provides common methods for unit conversion
 * 
 * @author Justas
 *
 */
public class UnitConversionUtils {

    /**
     * Converts density-independent pixels (dp) to real pixels (px)
     * 
     * @param activity
     * @param dp
     * @return
     */
    public static int dpToPx(Context context, int dp) {
        float result = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());

        return Math.round(result);
    }
}
